# Contributor: Laurent Bercot <ska-devel@skarnet.org>
# Maintainer: Laurent Bercot <ska-devel@skarnet.org>
pkgname=utmps
# NOTE: If you're upgrading to a new version that fixes some security
# vulnerability, rebuild the following aports:
# - busybox
# - dropbear
# - mingetty
# - openssh
# - util-linux
pkgver=0.1.2.3
pkgrel=2
pkgdesc="A secure utmp/wtmp implementation"
url=https://skarnet.org/software/utmps/
arch="all"
options="!check"  # No test suite
license="ISC"
_skalibs_version=2.14.3
_s6_version=2.13.1
depends="s6-ipcserver>=${_s6_version}"
depends_static="skalibs-static"
makedepends="skalibs-dev>=${_skalibs_version}"
subpackages="$pkgname-static $pkgname-libs $pkgname-dev $pkgname-doc $pkgname-openrc"
source="https://skarnet.org/software/utmps/utmps-$pkgver.tar.gz
	utmp-prepare.initd
	utmpd.initd
	wtmpd.initd
	btmpd.initd
	utmp-init.initd
	setup-utmp
	utmps.pc.in
	wtmpd.logrotate
	btmpd.logrotate
	0001-add-stub-utmp.h.patch"
install="utmps.pre-install"

build() {
	./configure \
		--enable-shared \
		--prefix=/usr \
		--disable-allstatic \
		--libexecdir="/usr/lib/$pkgname"
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m755 "$srcdir/utmp-prepare.initd" "$pkgdir/etc/init.d/utmp-prepare"
	install -D -m755 "$srcdir/utmpd.initd" "$pkgdir/etc/init.d/utmpd"
	install -D -m755 "$srcdir/wtmpd.initd" "$pkgdir/etc/init.d/wtmpd"
	install -D -m755 "$srcdir/btmpd.initd" "$pkgdir/etc/init.d/btmpd"
	install -D -m755 "$srcdir/utmp-init.initd" "$pkgdir/etc/init.d/utmp-init"
	install -D -m644 "$srcdir/wtmpd.logrotate" "$pkgdir/etc/logrotate.d/wtmpd"
	install -D -m644 "$srcdir/btmpd.logrotate" "$pkgdir/etc/logrotate.d/btmpd"
	install -D -m755 "$srcdir/setup-utmp" "$pkgdir/sbin/setup-utmp"
	sed -e "s/@@VERSION@@/$pkgver/g; s/@@SKALIBS_VERSION@@/${_skalibs_version}/g;" "$srcdir/$pkgname.pc.in" > "$srcdir/$pkgname.pc"
	install -D -m 0644 "$srcdir/$pkgname.pc" "$pkgdir/usr/lib/pkgconfig/$pkgname.pc"
	mkdir -p "$pkgdir/usr/share/doc"
	cp -a "$builddir/doc" "$pkgdir/usr/share/doc/$pkgname"
}

sha512sums="
41822b5ef582c86cd2439f13c88871bef2d496e6c7ae5493d9e2be70c7cf2f25656dedf045b4dbe925b1c6b3bfbadc7430a898ccc56951f096e768990a9735df  utmps-0.1.2.3.tar.gz
05d730a7ac770e91617a9db2b250c818f7733a3cbba3e539dbea23efeea71f65b059ec7778648bbedc2a6ac3b7907ac49d786cdadcfb716b29d8e9ce514d0f3a  utmp-prepare.initd
9c38e3fa6cac5d94eaa284adf21f47c01aa166c694a013c11c072727a3558b197a0de4c64e96e2f53991e3a485a68fd866fafd21e551ae00c3efbc6eed715f93  utmpd.initd
98473acb96cb647867c2c09779cfea15629d1f5baab3b122298a57c061a044746c514b883bb012065aeab217c856fb8713e0baad1c0f708973a9a4980de1d461  wtmpd.initd
974a21693f811cc7ad284e73644040cf43ffbedfaa77c91e4c822b5f8f184cf59b2a5ec15263880157bf7334bbf61a746b85bb5f2fa5c983b00a983f831c90dc  btmpd.initd
d817c43b47893777b88f8e7c20fa6294a096cfa060f22f6355add4202c86c420fe2a8be83982786c05410add5268e5d8e558105ef4105f40b83e0ce00dcc46f1  utmp-init.initd
b6249ae817641b93aaa37842efe4fe6f9055f1fe4581edbc94f037e5d63b01ebd31136fb3cbf563c887ecd8f4764a5a92d351ca6f63e24e8e6bb423a2d5196ff  setup-utmp
bf4c0cc09095dde3f00d2d0205ac1492a4d136d70c559ac2f4c387b40842d45f942fd7eea33d1d018f8791ed6ce5c285273769de788016b319f1a753fcca42a2  utmps.pc.in
5ade986bbed30ea82b8806a3d7a0ab09a7203fb8e4c9b8785e2d549973b33644a51c522cc8891a09d5016d4b47bf848224d10d0b9834a4c77929e68c7b95d293  wtmpd.logrotate
e085ca6d4ad3817dccb7de7f7feafad586ef567b7f81fcb7ffaf1cec75a0bc18a2023cfe0761f125d4a21975e4754d235e9bd54ed2246f9c1f17607fc0cb00de  btmpd.logrotate
0512f0daa216919a886e6a8e5a73db1d29acd66d929f38d5df40bd55f0d446402610c59da12688b75c3c1230af9b1929793ed8bfc9b4593851bf496fc0a8d835  0001-add-stub-utmp.h.patch
"
